package com.zbh.uexam.domain.enums;

import lombok.Data;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author zhoubh
 * @Date 2021/5/11 14:43
 * @Version 1.0
 * @description:
 */
public enum GradeLevelEnum {
    GradeOne(1, "一年级"),
    GradeTwo(2, "二年级"),
    GradeThree(3, "三年级"),
    GradeFor(4, "四年级"),
    GradeFive(5, "五年级"),
    GradeSix(6, "六年级"),
    GradeSeven(7, "初一"),
    GradeEight(8, "初二"),
    GradeNine(9, "初三"),
    GradeTen(10, "高一"),
    GradeEleven(11, "高二"),
    GradeTwelve(12, "高三"),
    GradeThirteen(13, "大一"),
    GradeFourteen(14, "大二"),
    GradeFifteen(15, "大三"),
    GradeSixteen(16, "大四");


    private static final Map<Integer, GradeLevelEnum> keyMap = new HashMap<>();

    private static final Map<String, GradeLevelEnum> valueMap = new HashMap<>();

    static {
        for (GradeLevelEnum item : GradeLevelEnum.values()) {
            keyMap.put(item.getCode(), item);
        }
        for (GradeLevelEnum item : GradeLevelEnum.values()) {
            valueMap.put(item.getName(), item);
        }
    }

    public static GradeLevelEnum fromCode(Integer code) {
        return keyMap.get(code);
    }

    public static GradeLevelEnum fromValue(String name) {
        return valueMap.get(name);
    }



    String name;
    int code;
    GradeLevelEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
